<?php
ob_start();
?>
<html>
<head>
	<title></title>
	<style type="text/css">
	body {margin:0px;padding:0px;background-color:transparent;}
	</style>
</head>
<body>
<?php
if (!isset($_GET['id']))
{
	exit('No ID defined!');
}

if (!is_numeric($_GET['id']))
{
	exit('Invalid ID!');
}

$iId = $_GET['id'];

define('PHPFOX_AD', dirname(dirname(dirname(__FILE__))) . '/file/cache/ads_' . $iId . '.php');

if (file_exists(PHPFOX_AD))
{
	$sHtml = ob_get_contents();
	
	$sAdId = 'ads_' . $iId;
	$sContent = file_get_contents(PHPFOX_AD);	
	$sContent = str_replace('$this->' . $sAdId, '$aAds', $sContent);
	$sContent = str_replace(array('<?php', '?>'), '', $sContent);
	eval($sContent);	
	$iTotal = count($aAds);
	$iRand = (rand(1,$iTotal)-1);
	
	ob_clean();
	
	echo $sHtml;
	echo (isset($aAds[$iRand]) ? $aAds[$iRand] : '');
}

?>
</body>
</html>
<?php
ob_end_flush();
?>